package com.cavy.platform.server.domain;

import lombok.Data;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by tangxu on 18-7-10.
 */
@Data
public abstract class AbstractRegexp implements RegexpValidator {
    protected String regexp;

    @Override
    public boolean validateValue(String value) {
        Pattern pattern = Pattern.compile(getRegexp());
        Matcher matcher = pattern.matcher(value);

        return matcher.matches();
    }
}
